<include file="public@header"/>
</head>
<style>
    #dh ul{
        padding: 0px;
        
    }
    #dh {
        margin:0px auto; 
    }
    #dh ul li {
        list-style: none;
        float: left;
    }
    #dh ul li a:hover{
        background-color: #FF9999;
    }
    #dh ul:hover{
        display: block;
    }
    #dh ul li ul{
        background-color: #0099CC;
        position: absolute;
        display: none;
    }
    #dh ul li ul li{
        float: none;
        background-color: #F0F0F0;
    }
    #dh ul li ul li a{
        font-size: 15px;
        font-weight: px;
    }
    #dh ul li:hover ul{             /*二级菜单的触发点*/
        display: block;
    }
</style>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="javascript:;">域名列表</a></li>
        <li><a href="{:url('Alsdk/AddLiveDomain')}">添加域名</a></li>
    </ul>
    <form class="well form-inline margin-top-20" method="post" action="{:url('Alsdk/DescribeUserDomains')}">
        直播域名:
        <input type="text" class="form-control" name="keyword" style="width: 200px;"
               value="{$search['keyword']|default=''}" placeholder="请输入直播域名...">
        <input type="submit" class="btn btn-primary" value="搜索"/>
        <a class="btn btn-danger" href="{:url('Alsdk/DescribeUserDomains')}">清空</a>
    </form>
    <form class="js-ajax-form" action="" method="post">
        <div class="table-actions">
            <!-- <a class="btn btn-danger btn-sm meetingDelete">批量删除</a>
            <a class="btn btn-primary btn-sm meetingAuditFail">批量审核不通过</a> -->
            <!-- <a class="btn btn-primary btn-sm meetingAuditPass">批量审核通过</a> -->
        </div>
        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th width="15">
                    <label>
                        <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                    </label>
                </th>
                <notempty name="category">
                    <th width="50">{:lang('SORT')}</th>
                </notempty>
                <th>直播域名名称</th>
                <th>CNAME域名</th>
                <th>业务类型</th>
                <th width="100">创建时间</th>
                <th width="100">修改时间</th>
                <th>备注</th>
                <th>状态</th>
                <th>region</th>
                <th>操作</th>
            </tr>
            </thead>
            <foreach name="list" item="vo">
                <tr>
                    <td>
                        <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
                               value="{$vo->DomainName}" title="ID:{$vo->DomainName}">
                    </td>
                    <td>{$vo->DomainName}</td>
                    <td>{$vo->Cname}</td>
                    <td>{$vo->CdnType}</td>
                    <td>{$vo->GmtCreated}</td>
                    <td>{$vo->GmtModified}</td>
                    <td>{$vo->Description}</td>
                    <?php $status = $vo->DomainStatus ;?>
                    <td>
                        <if condition="$status eq 'online'" />启用
                        <elseif condition="$status eq 'offline'" />停用
                        <elseif condition="$status eq 'configuring'" />配置中
                        <elseif condition="$status eq 'configure_failed'" />配置失败
                        <elseif condition="$status eq 'checking'" />正在审核
                        <elseif condition="$status eq 'check_failed'" />审核失败
                        </if>
                    </td>
                    <td>{$vo->RegionName}</td>
                    <td>
                        <?php $cdnType = $vo->CdnType ;?>
                        <if condition="($cdnType eq 'liveEdge') OR ( $cdnType eq 'liveVideo')">
                            <div id="dh">
                                <ul>
                                    <li><a class="btn btn-primary btn-sm" href="#">管理</a>
                                        <ul>
                                            <if condition="$cdnType eq 'liveEdge'">
                                                <li><a href="{:url('Alsdk/AddLiveDomainMapping',array('domain'=>$vo->DomainName))}">>添加映射</a></li>
                                            </if>
                                            <if condition="$cdnType eq 'liveVideo'">
                                                <li><a href="{:url('Alsdk/DescribeLiveStreamTranscodeInfo',array('domain'=>$vo->DomainName))}">>转码模板配置</a></li>
                                                <li><a href="{:url('Alsdk/DescribeLiveRecordConfig',array('domain'=>$vo->DomainName))}">>录制配置</a></li>
                                                <!-- <li><a href="#">>审核</a></li>
                                                <li><a href="#">>拉流</a></li>
                                                <li><a href="#">>全球加速配置</a></li> -->
                                            </if>
                                        </ul>
                                    </li>
                                </ul>
                            </div>
                            <a class="btn btn-default btn-sm" style="margin:1px;" href="{:url('Alsdk/DescribeLiveDomainDetail',array('domain'=>$vo->DomainName))}">查看详情</a>
                            <a class="btn btn-danger btn-sm" style="margin:1px;" onclick="DeleteLiveDomain('{$vo->DomainName}')">删除</a>
                        </if>
                        <if condition="($status eq 'online') AND (($cdnType eq 'liveEdge') OR ( $cdnType eq 'liveVideo'))" />
                            <a class="btn btn-warning btn-sm" style="margin:1px;" onclick="StatusLiveDomain('{$vo->DomainName}', 'online')">停用</a>
                        <elseif condition="($status eq 'offline') AND (($cdnType eq 'liveEdge') OR ( $cdnType eq 'liveVideo'))" />
                            <a class="btn btn-success btn-sm" style="margin:1px;" onclick="StatusLiveDomain('{$vo->DomainName}', 'offline')">启用</a>
                        </if>
                    </td>
                </tr>
            </foreach>
            <tfoot>
             <tr>
                <th width="15">
                    <label>
                        <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                    </label>
                </th>
                <notempty name="category">
                    <th width="50">{:lang('SORT')}</th>
                </notempty>
                <th>直播域名名称</th>
                <th>CNAME域名</th>
                <th>业务类型</th>
                <th width="100">创建时间</th>
                <th width="100">修改时间</th>
                <th>备注</th>
                <th>状态</th>
                <th>region</th>
                <th>操作</th>
            </tr>
            </tfoot>
        </table>
        <!-- <div class="table-actions">
            <a class="btn btn-danger btn-sm meetingDelete">批量删除</a>
            <a class="btn btn-primary btn-sm meetingAuditFail">批量审核不通过</a>
            <a class="btn btn-primary btn-sm meetingAuditPass">批量审核通过</a>
        </div> -->
        <ul class="pagination">{$meetingList['page']|default=''}<li class="page item"><a class="page link" href="#">总数：{$count}条</a></li></ul>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
    // 查看详情
    function LookLiveDomain(domain) {
        openIframeLayer("{:url('Alsdk/DescribeLiveDomainDetail')}?domain=" + domain, domain+'-基本信息', {
            area: ['700px', '650px'],
            btn: ['关闭'],
        });
    }

    // 删除
    function DeleteLiveDomain(domain)
    {
        var data = {
            'domain':domain,
        }
        art.dialog({
            id: 'warning',
            icon: 'warning',
            title: '提示',
            content: '确定删除此域名？',
            cancelVal: '关闭',
            ok: function () {
               myAjax("{:url('Alsdk/DeleteLiveDomain')}", data)
            }
        });
    }

    // 启用停用
    function StatusLiveDomain(domain, status){
        if ( status == 'online' ) {
            var msg = '确定停用域名：'+domain
        } else if ( status == 'offline' ) {
            var msg = '确定启用域名：'+domain
        }
        var data = {
            'domain':domain,
            'status':status
        }
        art.dialog({
            id: 'warning',
            icon: 'warning',
            title: '提示',
            content: msg,
            cancelVal: '关闭',
            ok: function () {
               myAjax("{:url('Alsdk/StatusLiveDomain')}", data)
            }
        });
    }

    // 执行提交
    function myAjax(url, data){
        $.ajax({
            url: url,
            dataType: 'json',
            data: data,
            type: "POST",
            success: function(data){
                if (data.code == '1') {
                    noty({
                        text: data.msg,
                        type: 'success',
                        layout: 'topCenter',
                        modal: true,
                        timeout: 800,
                        callback: {
                            afterClose: function () {
                                if (data.url) {
                                    window.location.href = data.url;//返回带跳转地址              
                                } else {
                                    //刷新当前页
                                    reloadPage(window);
                                }
                            }
                        }
                    }).show();
                } else if (data.code == '0') {
                    art.dialog({
                        content: data.msg,
                        icon: 'warning',
                        ok: function () {
                            this.title(data.msg);
                            return true;
                        }
                    });
                }
            }
        }); 
    }

</script>
</body>
</html>